package com.qf.day08.bookstore.impl;

import com.qf.day08.bookstore.bookstore.BookStore;
import com.qf.day08.bookstore.service.BookStoreMenuService;
import com.qf.day08.bookstore.service.BookStoreService;


import java.util.Scanner;

public class BookStoreMenuImpl implements BookStoreMenuService {


    @Override
    public void show() {
        BookStoreService bookStoreService = new BookStoreImpl();
        Scanner scanner = new Scanner(System.in);
        while (true){
            System.out.println("请输入数字选择 1.增加 2.删除 3.修改 4.查找 5.退出");
            int num=scanner.nextInt();
            switch (num){
                case 1:
                    System.out.println("输入id");
                    String id=scanner.next();
                    System.out.println("输入书名");
                    String name=scanner.next();
                    System.out.println("输入作者");
                    String autor=scanner.next();
                    BookStore bookStore=new BookStore(id,name,autor);
                    boolean addFlag = bookStoreService.addBook(bookStore);
                    if(addFlag){
                        System.out.println("添加成功");

                    }else {
                        System.out.println("添加失败");
                    }
                    break;
                case 2:
                    System.out.println("输入想删除的id号");
                    String idDelet=scanner.next();
                    boolean deleteFlag = bookStoreService.deleteBook(idDelet);
                    if(deleteFlag){
                        System.out.println("删除成功");
                    }else {
                        System.out.println("删除失败");
                    }
                    break;
                case 3:
                    break;
                case 4:
                    break;
                case 5:
                    return;
                default:
                    System.out.println("输入错误,请重新输入");
                    break;
            }
        }
    }
}
